{extend name="table"}

{block name="button"}
<!--{if auth("add")}-->
<button data-table-id="TableLists" data-open='{:url("add")}'
  class='layui-btn layui-btn-sm layui-btn-primary'>添加数据</button>
<!--{/if}-->

<!--{if auth("remove")}-->
<!--<button data-table-id="TableLists" data-action='{:url("remove")}' data-rule="id#{id}" data-confirm="确定要批量删除数据吗？" class='layui-btn layui-btn-sm layui-btn-primary'>批量删除</button>-->
<!--{/if}-->
{/block}

{block name='content'}
<div class="think-box-shadow">
  {include file='inbound/index_search'}
  <table id="TableLists" data-url="{:sysuri()}" data-target-search="form.form-search"></table>
</div>
{/block}

{block name='script'}
<script>
  $(function () {
    $('#TableLists').layTable({
      even: true, height: 'full',
      sort: { field: 'id', type: 'desc' },
      cols: [[
        { checkbox: true, fixed: true },
        { field: 'bill_no', title: '订单号', minWidth: 140, align: 'center' },
        { field: 'user_name', title: '添加人员', minWidth: 80, align: 'center' },
        { field: 'total_weight', title: '总重量', minWidth: 80, align: 'center' },
        { field: 'total_num', title: '总件数', minWidth: 100, align: 'center' },
        { field: 'total_price', title: '总金额', minWidth: 100, align: 'center' },
       
        { field: 'depart_name', title: '出发地', minWidth: 100, align: 'center' },
        { field: 'receiver_name', title: '目的地仓库', minWidth: 100, align: 'center' },
        { field: 'car_number', title: '车牌号', minWidth: 100, align: 'center' },
        { field: 'create_date', title: '发货日期', minWidth: 170, align: 'center' },
        { toolbar: '#toolbar', title: '操作面板', minWidth: 150, align: 'center', fixed: 'right' }
      ]]
    });

    // 数据状态切换操作
    layui.form.on('switch(StatusSwitch)', function (obj) {
      var data = { id: obj.value, status: obj.elem.checked > 0 ? 1 : 0 };
      $.form.load("{:url('state')}", data, 'post', function (ret) {
        if (ret.code < 1) $.msg.error(ret.info, 3, function () {
          $('#TableLists').trigger('reload');
        });
        return false;
      }, false);
    });
  });
</script>

<!-- 数据状态切换模板 -->
<script type="text/html" id="StatusSwitchTpl">
    <!--{if auth("state")}-->
<input type="checkbox" value="{{d.id}}" lay-skin="switch" lay-text="已激活|已禁用" lay-filter="StatusSwitch"
  {{d.status>0?'checked':''}}>
<!--{else}-->
{{d.status ? '<b class="color-green">已启用</b>' : '<b class="color-red">已禁用</b>'}}
<!--{/if}-->
</script>

<script type="text/html" id="toolbar">


 <!--{if auth('edit')}-->
<a class="layui-btn layui-btn-primary layui-btn-sm" data-title="编辑数据" data-open='{:url("edit")}?id={{d.id}}'>编 辑</a>
<!--{/if}-->

<!--{if auth('detail')}-->
<a class="layui-btn layui-btn-primary layui-btn-sm" data-title="编辑数据" data-open='{:url("detail")}?id={{d.id}}'>详 情</a>
<!--{/if}-->

<!--{if auth('remove')}-->
<!--    <a data-action='{:url("remove")}' data-value="id#{{d.id}}" data-confirm="确认要删除这条记录吗？" class="layui-btn layui-btn-sm layui-btn-danger">删 除</a>-->
<!--{/if}-->
</script>
{/block}